package com.example.project.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.project.entity.Orders;
import com.example.project.mapper.OrdersMapper;

/**
 * 订单管理Controller
 *
 * @author changyao
 * @date 2024-12-23
 */
@RestController
@RequestMapping("/project/orders")
public class OrdersController
{
    @Autowired
    private OrdersMapper ordersMapper;

    /**
     * 查询订单管理列表
     */
    @GetMapping("/list")
    public List<Orders> list()
    {
        QueryWrapper<Orders> queryWrapper=new QueryWrapper<>();
        return ordersMapper.selectList(queryWrapper);
    }




    /**
     * 获取订单管理详细信息
     */
    @PostMapping("/detil")
    public Orders getInfo(@RequestBody Orders orders)
    {
        return ordersMapper.selectById(orders);
    }


    /**
     * 新增订单管理
     */
    @PostMapping("/add")
    public int add(@RequestBody Orders orders)
    {
        return ordersMapper.insert(orders);
    }

    /**
     * 修改订单管理
     */
    @PostMapping("/edit")
    public int edit(@RequestBody Orders orders)
    {
        return ordersMapper.updateById(orders);
    }

    /**
     * 删除订单管理
     */
	@PostMapping("/del")
    public int remove(@RequestBody Orders orders)
    {
        return ordersMapper.deleteById(orders);
    }
}
